import axios from 'axios'

if (process.env.NODE_ENV === 'production') {
    axios.defaults.baseURL = 'http://lottery.21cst.cn'
  }
console.log(axios.defaults.baseURL)
const service = axios.create({
  baseURL: '/api',
  timeout: 50000 // 请求超时时间
});

export default {
  get(url, data, loading) {
    data = data || {};
    return service({url, data, method: 'get', loading});
  },
  post(url, data, isLoading) {
    data = data || {};
    let param = {url, data, method: 'post'};
    if (data && data.currentPage) {
      data.pageIndex = data.currentPage;
      delete data.currentPage;
    }
    if (isLoading) {
      util.showLoading();
    }
    return service(param);
  }
}

